/**
 * 
 */
package com.zhaoyan.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhaoyan.mapper.ComMapper;
import com.zhaoyan.pojo.Company;
import com.zhaoyan.pojo.Plan;
import com.zhaoyan.pojo.PlanVo;
import com.zhaoyan.service.ComService;

/**
 * @author zhaoyan
 *
 * 2020年1月29日
 */
@Service
public class ComServiceImpl implements ComService{
	
	@Autowired
	private ComMapper comMapper;

	@Override
	public int addPlan(String[] split) {
		// TODO Auto-generated method stub
		
		//信号提速电源屏2套AA3200000.00AA二道河至老牛湾无缝线路改造工程甲供AA欧阳尚明AA大准铁路公司
		Plan plan = new Plan();
		
		plan.setProname(split[0]);
		
		plan.setMoney(Double.parseDouble(split[1]));
		
		plan.setDetails(split[2]);
		
		plan.setPromanager(split[3]);
		
		Company findCom = comMapper.findCom(split[4]);
		
		plan.setDepartid(findCom.getDepartId());
		
		int num = comMapper.addPlan(plan);
		
		if(num > 0) {
			return 1;
		}
		
		return 0;
	}

	@Override
	public PageInfo<Plan> findPlan(PlanVo plan,Integer pageNum) {
		// TODO Auto-generated method stub
		
		
		PageHelper.startPage(pageNum, 5);
		
		return new PageInfo<Plan>(comMapper.findPlan(plan));
	}

	@Override
	public Plan showDetail(Integer id) {
		// TODO Auto-generated method stub
		return comMapper.findPlanById(id);
	}

	@Override
	public List<Company> findComList() {
		// TODO Auto-generated method stub
		return comMapper.findComany();
	}

	@Override
	public Integer addPlan(Plan plan) {
		// TODO Auto-generated method stub
		return comMapper.addPlan(plan);
	}
	
	
	
	

}
